package 区间选点;

import java.util.*;

public class Main {
    static int N = 100010;
    static PII[] q = new PII[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            int l = in.nextInt();
            int r = in.nextInt();
            q[i] = new PII(l, r);
        }
        Arrays.sort(q, 0, n);
        int r_max = Integer.MIN_VALUE, res = 0;
        for (int i = 0; i < n; i++) {
            if (q[i].l > r_max) {
                res++;
                r_max = q[i].r;
            }
        }
        System.out.println(res);
    }
}

class PII implements Comparable<PII> {
    int l, r;

    public PII(int l, int r) {
        this.l = l;
        this.r = r;
    }

    @Override
    public int compareTo(PII o) {
        return Integer.compare(this.r, o.r);
    }
}
